package com.atguigu.study.base;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class ReentrantLockDemo {
    public synchronized void a(){
        this.b();
        System.out.println(" a" );
    }
    public synchronized void b(){
        System.out.println(" b ");
    }
    private final Lock lock=new ReentrantLock();
    public void c(){
        lock.lock();
        try {
            d();
            System.out.println(" c");
        } finally {
            lock.unlock();
        }
    }
    public void d(){
        lock.lock();
        try {

            System.out.println(" d");
        } finally {
            lock.unlock();
        }
    }

    public static void main(String[] args) {
        new ReentrantLockDemo().c();
    }
}
